package com.niiwoo.civet.account.service.local.openAccount2.account;

import com.niiwoo.civet.account.dao.entity.AccountPerson;
import com.niiwoo.civet.account.dao.mapper.AccountPersonMapper;
import com.niiwoo.civet.account.enums.AccountTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class AccountPersonHandler implements AccountExtendOperation<AccountPerson> {

    @Autowired
    AccountPersonMapper accountPersonMapper;

    @Override
    public boolean save(AccountPerson accountPerson) {
        return accountPersonMapper.insertSelective(accountPerson) > 0;
    }

    @Override
    public boolean update(AccountPerson accountPerson) {
        return accountPersonMapper.updateByPrimaryKeySelective(accountPerson) > 0;
    }

    @Override
    public AccountPerson getByAccountId(long accountId) {
        return accountPersonMapper.selectByPrimaryKey(accountId);
    }

    @Override
    public AccountTypeEnum getType() {
        return AccountTypeEnum.PERSONAL;
    }

}
